import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/17 16:26
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    class ATM {

        private long[] cnt;
        private int[] nums;

        public ATM() {
            this.cnt = new long[5];
            this.nums = new int[]{20, 50, 100, 200, 500};
        }

        public void deposit(int[] banknotesCount) {
            for (int i = 0; i < 5; i++) {
                cnt[i] += banknotesCount[i];
            }
        }

        public int[] withdraw(int amount) {
            int[] res = new int[5];
            for (int i = 4; i >= 0; i--) {
                if (amount >= nums[i] && cnt[i] > 0) {
                    int num = (amount / nums[i]) > cnt[i] ? (int) cnt[i] : (amount / nums[i]);
                    res[i] = num;
                    amount -= nums[i] * num;
                }
            }
            // 如果能取出来，再对cnt真正操作
            if (amount == 0) {
                for (int i = 0; i < 5; i++) {
                    cnt[i] -= res[i];
                }
                return res;
            }
            return new int[]{-1};
        }

    }
}
